<?php
session_start();
include('connect.php');
$sessionID = $_SESSION['SessionID'];
// Derzeitige Anzahl an Freunden des Spielers, die online sind aus Datenbank lesen
		$idList = array();		
		$onlineList = array();
		$sql = mysql_query("SELECT * FROM tblfriends WHERE ID LIKE '$sessionID'");
		
		while($row = mysql_fetch_array($sql,MYSQL_ASSOC)) {
			$friendID = $row['FriendID'];
			array_push($idList, $friendID);
		}
		
		for($i = 0; $i < count($idList); $i++) {
			$sql = mysql_query("SELECT Username FROM tblusers WHERE ID LIKE '$idList[$i]' AND Online LIKE '1'");
			if(mysql_num_rows($sql) > 0) {
				array_push($onlineList, mysql_result($sql, 0));
			}
		}
		
		$friendsonline = count($onlineList);
echo $friendsonline;
		
?>